package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.domain.StrategyComment;
import cn.wolfcode.trip.base.domain.Travel;
import cn.wolfcode.trip.base.mapper.StrategyCommentMapper;
import cn.wolfcode.trip.base.mapper.StrategyMapper;
import cn.wolfcode.trip.base.mapper.TravelMapper;
import cn.wolfcode.trip.base.query.CollectQueryObject;
import cn.wolfcode.trip.base.service.ICollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollectServiceImpl implements ICollectService {
    @Autowired
    private StrategyMapper strategyMapper;
    @Autowired
    private TravelMapper travelMapper;
    @Autowired
    private StrategyCommentMapper commentMapper;


    @Override
    public void addStrategyCollect(CollectQueryObject qo) {
        strategyMapper.saveCollect(qo);
    }

    @Override
    public void removeStrategyCollect(CollectQueryObject qo) {
        strategyMapper.deleteCollect(qo);
    }

    @Override
    public void removeTravelCollect(CollectQueryObject qo) {
        travelMapper.deleteCollect(qo);
    }

    @Override
    public void addTravelCollect(CollectQueryObject qo) {
        travelMapper.saveCollect(qo);
    }

    @Override
    public Integer countTravelCollect(Long travelId) {

        return travelMapper.countCollect(travelId);
    }

    @Override
    public Integer travelIsCollect(Long userId, Long travelId) {
        return travelMapper.isCollect(userId,travelId);
    }

    @Override
    public Integer countStrategyCollect(Long strategyId) {
        return strategyMapper.countCollect(strategyId);
    }

    @Override
    public List<Travel> selectCollectByUserId(Long userId) {
        return travelMapper.selectCollectByUserId(userId);
    }

    @Override
    public List<Strategy> selectStrategyCollectByUserId(Long userId) {

        return strategyMapper.selectStrategyCollectByUserId(userId);
    }

    @Override
    public Integer strategyIsCollect(Long userId, Long strategyId) {
        return strategyMapper.isCollect(userId,strategyId);
    }

    //评论收藏
    @Override
    public void addCommentCollect(CollectQueryObject qo) {
        commentMapper.saveCommentCollect(qo);
    }

    @Override
    public void removeCommentCollect(CollectQueryObject qo) {
        commentMapper.deleteCommentCollect(qo);
    }

    @Override
    public Integer countCommentCollect(Long commentId) {
        return commentMapper.countCommentCollect(commentId);
    }

    @Override
    public Integer commentIsCollect(Long userId, Long commentId) {
        return commentMapper.commentIsCollect(userId,commentId);
    }

    @Override
    public List<StrategyComment> selectCommentCollectByUserId(Long userId) {
        return commentMapper.selectCommentCollectByUserId(userId);
    }

}
